/* 缓动插件 */
// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	}
});

(function() {
	$.suning || ($.suning = {});
	$.suning.productView = {};
	
	//继承
	$.suning.productView.extend = function (subClass, superClass) {
		var F = function() {};
		F.prototype = superClass.prototype;
		subClass.prototype = new F();
		superClass.prototype.constructor = superClass;
		subClass.prototype.constructor = subClass;
		subClass.base = superClass.prototype;
	}
})();
//快捷方式
$PV = $.suning.productView;//快捷方式


//选择城市
$PV.cityBox = function() {
	var city = $("#citybox");
	var btn,isopen = false,ref, cityc,offset,poffset, active = false, timeout;
	var url = 'city.htm';
	var nowprovince = "";
	var onChange;
	return {
		init: function(fn) {
			onChange = fn || (function(cname) {alert(cname)})
			if (city.length == 0) {
				return;
			}
			ref = this;
			
			var iframe = document.createElement("iframe");
			iframe.id = "temp_iframe";
			btn = $("#citybox_btn").click(function(e) {
				city.after(iframe);
				if(city.css('display')=="none"){
					$(this).addClass('select');	
					city.show();
					$(iframe).css({
						width : city.width(),
						height : city.height(),
						position : "absolute",
						"z-index" : 10,
						opacity : 0,
						top : 25,
						left : 75
					});
				}else{
					$(this).removeClass('select');	
					city.hide();
				}											   
				e.preventDefault();
				
			})
			
			city.mouseover(function(){
				$(this).show();
				$("#citybox_btn").addClass('select');
				$("#citybox_btn02").addClass('select');
			}).mouseleave(function(){
				$(this).hide();
				$("#temp_iframe").remove();
				$("#citybox_btn").removeClass('select');
				$("#citybox_btn02").removeClass('select');
			});
			
			city.find("table a").click(function(e) {
				
				ref.x=parseInt($(this).offset().left-$(".province").offset().left);
				ref.y=parseInt($(this).offset().top-$(".province").offset().top);
				e.preventDefault();
				if (cityc != null) {
					cityc.remove();
					cityc = null;
				}
				active = false;
				clearTimeout(timeout);
				nowprovince = this.innerHTML;
				poffset = $(this).offset();
				var _this=this;
				(function() {
					var qp = nowprovince;
					$.get(url, function(data) {
						if (qp == nowprovince) {
							ref.addCity(data,$(_this).parent());
						}
				})})()
				city.find("table a").css({"z-index":0,"position":"relative"});
				$(this).css("z-index",100000);
				//$(this).css("border","1px solid #999999");
				$(this).css("position","relative");
				$(this).addClass('on').parent().parent().siblings().find('a').removeClass('on');
				$(this).addClass('on').parent().siblings().find('a').removeClass('on');
				$(this).addClass('on').siblings().removeClass('on');
				
			}).mouseleave(function(e) {
				timeout = setTimeout(function() {
					if (!active && cityc != null) {
						cityc.remove();
						$(".province").find('a').removeClass('on');
						cityc = null;
						city.css({"height":"auto"});
					}
				},200)
			});
			
			/* 关闭按钮 */
			city.find(".closeIco").click(function(event){
				city.hide();
				event.preventDefault();
			});
		},
		changeView: function() {
			city.css("display", isopen ? "none" : "block");
			if (!offset && !isopen) {
				offset = city.offset();
			}
			isopen = !isopen;
		},
		addCity: function(str,obj) {
			var re = /([A-Za-z]+)(.[^\|]+)/g;
				var o = {}
				while(r = re.exec(str)) {

					if (!o[r[1]]) {
						o[r[1]] = [r[2]];
					} else {
						o[r[1]].push(r[2]);
					}
				}

				var loc = 0;
				var template = '<table class="citys"><tr>';
				for (var i in o) {
					var temp = "";
					var temparr = o[i];
					for (var j=0 ;j<temparr.length; j++) {
						temp += '<a href="#">' + temparr[j] + '</a>'
					}
					template += '<td class="td03">' + temp + '</td>';
					template += "</tr><tr>";
					
					loc++;
				}
				template = template.substring(0, template.length-5) + "</table>";
				cityc = $(template);
				city.append(cityc);
				if(this.y+cityc.height()<180){
					city.css({"height":205});
				}else{
					city.css({"height":this.y+cityc.height()+30});
				}
				cityc.mouseover(function(e) {
					active = true;
				}).mouseleave(function(e) {
					active = false;
					cityc.remove();
					cityc = null;
					city.css({"height":"auto"});
					$(".province").find('a').removeClass('on');
				});
				cityc.find("a").click(function(e) {

					//onChange(this.innerHTML,this.name);
					$("#citybox_btn").removeClass('select');
					$("#citybox_btn02").removeClass('select');
					setTimeout(function(){
						city.hide();
						$("#citybox_btn").removeClass('select');
						$("#citybox_btn02").removeClass('select');	
						city.css({"height":"auto"});
						$("#temp_iframe").remove();
					},300);		
					$('#citybox_btn .ctext').html(this.innerHTML);
					$('#citybox_btn02').html(this.innerHTML);
					e.preventDefault();
				});
				cityc.css({left:10+"px" ,top:this.y+20+"px" });
				//cityc.css({left:this.x+"px" ,top:this.y+20+"px" });
		}
	}
}
/**
 * 	Add by 12050231
 */

function Product(){}

Product.prototype = {
	layload : function(box){
		var move;
		$(window).scroll(function(){
			move = setTimeout(function(){
				$(box).find("img").each(function(){
					if($(this).offset().top  < $(window).scrollTop() && $(this).attr("src2")){
						clearTimeout(move);
						return;
					}
					if($(window).scrollTop() > $(this).offset().top - $(window).height() && $(this).attr("src2")){
						$(this).attr("src", $(this).attr("src2")).removeAttr("src2");
					}
				});
			},1000);

			if(typeof box == "object" && $(window).scrollTop() > $(box.id).offset().top - $(window).height() && $(box.id).html().length < 10){
				var str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0" style="width:'+box.w+';height:'+box.h+';">\
                  <param name="movie" value="' +
               box.url +
                '" />\
                  <param name="quality" value="high" />\
                  <param name="wmode" value="transparent" />\
                  <embed src="' +
                box.url +
                '" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"  wmode="transparent" style="width:'+box.w+';height:'+box.h+';" >\
                    </embed></object>';

                $(box.id).html(str);

			}
		})
	},
	popBox : function(id, closeId, submit, hasMask){
		var box = document.getElementById(id);
		var winH = document.documentElement.scrollHeight;
		var winW = document.body.clientWidth;
		var isIE=!!window.ActiveXObject; 
		var isIE6=isIE&&!window.XMLHttpRequest;
		var _hasMask = hasMask ? 0 : 0.7;
		var mask = document.createElement("div");
		mask.id = "mask";
		box.style.display = "block";
		var boxL = winW / 2 - box.clientWidth / 2;
		var boxT =  (document.body.scrollTop || document.documentElement.scrollTop) + window.screen.height/2 - box.clientHeight / 2 - 100;
		mask.style.cssText = "position:absolute;top:0;left:0;background:#333;height:" + winH + "px;width:" + winW + "px;z-index:9999;opacity:" + _hasMask + ";filter:alpha(opacity=" + _hasMask * 100 + ");";
		document.body.appendChild(mask);
		if(isIE6){
			var iframe = document.createElement("iframe");
			iframe.style.position = "absolute";
			iframe.style.top = 0;
			iframe.style.left = 0;
			iframe.style.zIndex = "9999";
			iframe.style.height = winH + "px";
			iframe.style.width = winW - 10 + "px";
			iframe.style.filter = "alpha(opacity=0)";
			document.body.appendChild(iframe);
		}
		box.style.zIndex = "10000";
		box.style.cssText = " ;display:block;left:" + boxL + "px;top:" + boxT + "px;z-index:10000000;";
		document.getElementById(closeId).onclick = removeBox;
		if(document.getElementById(submit)){
			document.getElementById(submit).onclick = function(){
				removeBox();
			}	
		};
		function removeBox(){
			box.style.display = "none";
			mask.parentNode.removeChild(mask);
			if(isIE6){
				iframe.parentNode.removeChild(iframe);
			}
		}

	}
}
	

$PV.Ready = {
	init : function(){
		var imgload = new Product()
		imgload.layload("#detail_content");
		imgload.layload(".sidebox");
		imgload.layload({
			id : "#flash_zoushi",
			//url : flash的地址
			url : "data/zoushi.swf",
			w : "405px",
			h : "170px"
		});
		//分享
		//this.pro_share("#sn_share");
		//纠错弹窗
		this.pro_jiucuo("pro_wrongOut", "close_pro_wrongOut", "submit_pro_wrongOut");
		//
		this.pro_shoucang("popBox01", "close_popBox01", "submit_popBox01");
		//大图展示
		this.pro_view_slide();
		//评论跳转
		this.pro_comment_goto();
		//选择
		this.pro_choose();
		//放大镜
		this.pro_imgzoom(800, 800);
		//this.toggle("#compare_btn", "#comp3", "click" );
		//购物数量
		this.pro_Num(1,20, true);
		//滚动走马灯
		if($("body").hasClass("root1000")){
			this.pro_slide("#youhui_slide_box", "#youhui_slide", 328,2);
			this.pro_slide("#taocan_box1", "#taocan1", 560, 6);
			this.pro_slide("#taocan_box2", "#taocan2", 560, 6);
			this.pro_slide("#taocan_box3", "#taocan3", 560, 6);
			this.pro_fixed("#pro_detail_tab", 990);

		}else{
			//商品总览、参数、评论、知道、咨询、晒单选项卡固定
			this.pro_fixed("#pro_detail_tab", 1190);
			this.pro_slide("#youhui_slide_box", "#youhui_slide", 525, 3);
			this.pro_slide("#taocan_box1", "#taocan1", 760, 8);
			this.pro_slide("#taocan_box2", "#taocan2", 760, 8);
			this.pro_slide("#taocan_box3", "#taocan3", 760, 8);
		}
		

		
		//套餐选项卡

		this.pro_tab({
			btn : "#taocan_tab",
			box : "#taocan_tab_box"

		});
		//套餐优惠总选项卡
		this.pro_tab({
			btn : "#tcyh",
			box : "#tcyh_tab_box",
			boxClass : ".product_tab_box_tcyh",
			callback :　this.pro_dapei

		});
		//商品总览、参数、评论、知道、咨询、晒单选项卡
		this.pro_tab({
			btn : "#pro_detail_tab",
			box : "#pro_detail_tab_box",
			boxClass : ".pro_detail_tab_box",
			//对应的异步地址和方法，
			ajax_data : [
				//参数异步调用已屏蔽
				{url : "data/canshu.html", callback : function(){
						$PV.Ready.pro_hoverShow(".pro_para_table tr", ".erro_recovery");
						$PV.Ready.pro_tab({
							btn : "#pro_canshu_tab",
							box : "#pro_canshu_tab_box",
							boxClass : ".pro_para_table",
							callback : $PV.Ready.pro_canshu_more
						});
					}
				},
				{url : "data/pinglun.html", callback : function(){
						if($("body").hasClass("root1000")){
							$PV.Ready.pro_slide("#user_info_box", "#user_info", 450, 6);
						}else{
							$PV.Ready.pro_slide("#user_info_box", "#user_info", 620, 8);
						}
						$PV.Ready.pro_manyidu();
						$PV.Ready.pro_tab({
							btn : "#pro_pinglun_tab",
							box : "#pro_pinglun_tab_box"
						});
						$PV.Ready.toggle(".viewAll", ".showUp", "- 收起", "+ 查看全部回复");

					}
				},
				{url : "data/zixun.html", callback : function(){
						$PV.Ready.pro_tab({
							btn : "#pro_zixun_tab",
							box : "#pro_zixun_tab_box"
						});

					}
				},
				{url : "data/zhidao.html", callback : function(){
						$PV.Ready.pro_zhidao();

					}
				},
				{url : "data/shaidan.html"}
			]

		});

		
												
		this.pro_hoverShow(".pro_para_table tr", ".erro_recovery");

		this.pro_tab({
			btn : "#pro_canshu_tab",
			box : "#pro_canshu_tab_box",
			boxClass : ".pro_para_table",
			callback : $PV.Ready.pro_canshu_more
		});
		
		//商品总览、参数、评论、知道、咨询、晒单选项卡固定
		//this.pro_fixed("#pro_detail_tab", 1200);
		//倒计时
		new this.pro_time(600000, this.pro_reTime, "#qianggou", this.pro_time_callback).start();

		//视屏播放
		this.pro_video_show();

		
	},
	//
	pro_imgzoom : function(w, h) {
		var zoompos = {x:0,y:0};//定义一个对象，缓存x,y变量.
		var $pre = $("#preview");
		var $preimg = $pre.find("img");
		var p_w  = w;
		var p_h  = h;

		setTimeout(function(){
			if($("#PicView").find("img").height() < 400){

				$("#PicView").find("img").animate({"margin-top" : 30}, 1000);
				p_w = 612;
				p_h = 520;
				$("#preView_box").find("img").css({"margin-top" : 8})

			}
		},80);
		var delay;
		if(!!window.ActiveXObject&&!window.XMLHttpRequest){
			$pre.after("<iframe id='maskA'  style='position:absolute;border:none;opacity:0;filter:alpha(opacity=0);z-index:1;display:none;'></iframe>");
		}
		$("#PicView").bind("mouseover",function(e){
			var _e = e;
			var $this  = $(this);
			var img = new Image();
			delay = setTimeout(function(){
				$(img).load(function(){
				var $zoom = $this.find(".zoomplePopup");
				$zoom.show();
				$pre.fadeIn();
				
				$("#maskA").css({top:0,left:402,opacity:0,width:$pre.width(),height:$pre.height()}).show();
				$preimg.attr("src", $preimg.attr("src2"));
				PositionPopupZoom( $this , $zoom , _e.pageX , _e.pageY , p_w , p_h );
				$this.bind("mousemove",function(e){
					setTimeout(function(){
						PositionPopupZoom( $this , $zoom , e.pageX , e.pageY , p_w , p_h);
					},10);
				});
				}).attr("src", $preimg.attr("src2"));
			},300);
			
		}).bind("mouseleave",function(){
			if(!!window.ActiveXObject&&!window.XMLHttpRequest){
				$("#maskA").hide();
			}
			var $this  = $(this);
			var $zoom = $this.find(".zoomplePopup");
			$zoom.hide();
			$pre.fadeOut();
			$this.unbind("mousemove");
		}).mouseout(function(){
			clearTimeout(delay);
		});
		/*
			wrap : 当前绑定的元素
			zoom : 当前绑定的元素里的popupzoom元素
			x, y : 当前鼠标在页面上的位置
			w, h : 放大的图片的高度和宽度,用来计算比例
		*/
		function PositionPopupZoom( wrap , zoom , x , y , w , h){
			var wrapLeft = wrap.offset().left;
			var wrapTop =  wrap.offset().top;
			var zoomWidth = zoom.width();
			var zoomHeight = zoom.height();
			var wrapWidth = wrap.width();
			var wrapHeight = wrap.height();
			
			zoompos.x =  x -wrapLeft - (zoomWidth/2);
			zoompos.y =  y -wrapTop- (zoomHeight/2);
			if( zoompos.x <= 0 ){
				zoompos.x  =  0;
			}
			if( zoompos.y <= 0 ){
				zoompos.y  =  0;
			}
			if( zoompos.x + zoomWidth >= wrapWidth){
				zoompos.x  = wrapWidth  -  zoomWidth; 
			}
			if( zoompos.y + zoomHeight >= wrapHeight){
				zoompos.y  = wrapHeight  -  zoomHeight; 
			}
			//放大比例
			var xRatio = w / wrapWidth;  
			var yRatio = h / wrapHeight;
			//设置位置
			zoom.css({left:zoompos.x,top:zoompos.y});
			$preimg.css({left: -(zoompos.x * parseFloat(xRatio)) , top:  -(zoompos.y * parseInt(yRatio)) }); 
		}		

	},

	IE6 : function(callback){
		var isIE=!!window.ActiveXObject; 
		var isIE6=isIE&&!window.XMLHttpRequest;
		if(isIE6){
			callback();
		}
	},
	/**
	 * [toggle description]
	 * @param  {[string]} btn      [点击触发按钮外层容器]
	 * @param  {[string]} btnClass [点击触发按钮]
	 * @param  {[string]} text     [切换内容]
	 * @return {[type]}          [description]
	 */
	toggle : function(btn, btnClass, textUp, textDown){
		$(btn).find(btnClass).toggle(function(){
			$(this).text(textUp);
			$(this).parent().next().show();	
		},function(){
			$(this).text(textDown);
			$(this).parent().next().hide();
		})
	},
	/**
	 * [pro_hoverShow description]
	 * @param  {[string]} o   [触发元素]
	 * @param  {[sting]} box [触发显示元素]
	 * @param  {[string]} btn [可选，内部元素样式]
	 * @return {[type]}     [description]
	 */
	pro_hoverShow : function(o, box, btn){
		$(o).hover(function(){
			if(btn){
				$(this).find(btn).addClass("hover");
			}
			$(this).find(box).show();
		},function(){
			if(btn){
				$(this).find(btn).removeClass("hover");
			}
			$(this).find(box).hide();
		})
	},
	pro_view_slide : function(){
		var delay;
		var i = 0;
		var box = $("#preView_box");
		box.find("li").mouseover(function(){
			var _this = $(this);
			delay = setTimeout(function(){
				_this.addClass("cur").siblings().removeClass("cur");
				$("#PicView").find("img").attr("src",_this.find("img").attr("src2"));
				$("#preview").find("img").attr("src2", _this.find("img").attr("src2"));
			},200);
			
		}).mouseout(function(){
			clearTimeout(delay);
		});

		var up = $("#preView_box").find("p.up");
		var down = $("#preView_box").find("p.down");
		var len = $("#preView_box").find("li").length;
		var ul = $("#preView_box").find("ul");
		if(len <= 4){
			len = 4;
			down.find("a").addClass("false");
			up.find("a").addClass("false");
			return;
		}
		down.click(function(){
			i++;
			up.find("a").removeClass("false");
			if(i >= len - 4){
				i = len - 4;
				$(this).find("a").addClass("false");
			}
			move(i);
		})

		up.click(function(){
			down.find("a").removeClass("false");
			i--;
			if(i <= 0){
				i = 0;
				$(this).find("a").addClass("false");
			}
			move(i);
		})
		
		function move(i){
			ul.stop(true).animate({"margin-top" : -103 * i});
		}

	},
	pro_choose : function(){
		$("#pro_color,#pro_style").find("li:not('.disable')").hover(function(){
			$(this).addClass("hover");
		}, function(){
			$(this).removeClass("hover")
		}).click(function(){
			$(this).addClass("cur").siblings().removeClass("cur");	
			
		});
		$("#pro_color").find("li").click(function(){
			$("#color_value").text('"' + $(this).attr("title") + '"');
		});
		$("#pro_style").find("li:not('.disable')").click(function(){
			$("#style_value").text('"' + $(this).text() + '"');
		});
	},
	pro_Num : function(min, max, one){

		var mins = $("#pro_count").find("li.mins");
		var add = $("#pro_count").find("li.add")
		var input = $("#pro_count").find("input");
		var i = min;
		input.val(min);
		input.keyup(function(){
			i = $(this).val();
			if(parseInt($(this).val()) > max){
				$(this).val(max)
			}
			if(isNaN($(this).val()) || parseInt($(this).val()) == 0 || parseInt($(this).val()) < min || $(this).val() == ""){
				$(this).val(min)
			}
		});
		mins.click(function(){
			i--;
			if(i <= min){
				input.val(min);
				i = min;
			}else{
				input.val(i)
			}
		});
		add.click(function(){
			i++;
			if(i > max){
				i = max;
			}
			input.val(i);

			if(one){
				//i = 1;
				//input.val(i);
				$("#jnbt").fadeIn().delay(5000).fadeOut(500, function(){
					$("#jnbt").remove();
				});
			};
		});
		
		this.IE6(ie6Hover);
		function ie6Hover(){
			$(mins).hover(function(){
				$(this).addClass("hover");
			},function(){
				$(this).removeClass("hover");
			});
			$(add).hover(function(){
				$(this).addClass("hover");
			},function(){
				$(this).removeClass("hover");
			});
		}
			
	},
	/**
	 * [pro_tab description]
	 * @param  {[object]} opt [参数对象{}]
	 * @return {[type]}     [description]
	 */
	pro_tab : function(opt){
		var def = {
			btn : "",  
			btnClass : "cur",
			box : "",
			boxClass : ".product_tab_box",
			type : "click",
			more : "",
			callback : "",
			ajax_data : ""
		}
		$.extend(def, opt);

		$(def.btn).find("li").bind(def.type, function(){
			var index = $(this).index();
			$(this).addClass(def.btnClass).siblings().removeClass(def.btnClass);
			$(def.box).find(def.boxClass).eq(index).show().siblings(def.boxClass).hide();
			if(typeof def.callback == "function"){
				def.callback(index, def);
			}
			if(typeof def.ajax_data == "object" && index > 1 && $(def.box).find(def.boxClass).eq(index).html().length < 20){

				$(def.box).find(def.boxClass).eq(index).html("<div class='loading' style='padding:20px 0'></div>");
				$.get(def.ajax_data[index-1].url, function(data){
					$(def.box).find(def.boxClass).eq(index).html(data);
					if(typeof def.ajax_data[index-1].callback == "function"){
						def.ajax_data[index-1].callback();
					}

				})
			}

			//only fix for safari scroll
			if(def.btn == "#pro_detail_tab"){
				//$(window).scrollTop($("#placeHolder_fixed").offset().top);
			}
		});
		


	},
	pro_slide : function(box, moveBox, px, step, check){
		var i = 0;
		var li = check ? "li:visible" : "li";
		var stepTemp = step ? $(moveBox).find(li).length / step : $(moveBox).find(li).length;

		var lenTemp = stepTemp == Math.floor(stepTemp) ? Math.floor(stepTemp) - 1 : Math.floor(stepTemp);
		var len = lenTemp ;
		$(box).find(".right").click(function(){
			i++;
			if(i > len){
				i = 0;
			}
			move(i);
		});
		$(box).find(".left").click(function(){
			i--;
			if(i <= 0){
				i = 0;
			}
			move(i);
		});
		function move(i){
			$(moveBox).stop().animate({left : -i * px});
		}
		this.IE6(ie6Hover);
		function ie6Hover(){

			$(box).find(".right").hover(function(){
				$(this).toggleClass("hover");
			});

			$(box).find(".left").hover(function(){
				$(this).toggleClass("hover");
				$(this).find("span").toggleClass("leftfix");
			});

		}
	},
	pro_dapei : function(i, def){
		
		$("#youhui_tab").find("li").click(function(){
			var index = $(this).index();
			$("#youhui_slide").find("li").each(function(){
				$("#youhui_slide").find("li").hide();
				$("#youhui_slide").find("li.type" + index ).show();
			});
			if(index == 0){
				$("#youhui_slide").find("li").show();
			}
			$(this).addClass(def.btnClass).siblings().removeClass(def.btnClass);
			$("#youhui_slide").css("left",0);
			var len1 = 4, len2 = 7, width1000 = 525, step1 = 6, step2 = 3;
			if($("body").hasClass("root1000")){
				len1 = 3, len2 = 5, width1000 = 328, step1 = 6, step2 = 2;
			}
			if($("#youhui_slide").find("li:visible").length < len1 ){
				$("#youhui_slide_box").find(".btn").unbind("click");
			}else{
				$PV.Ready.pro_slide("#youhui_slide_box", "#youhui_slide", width1000, step2, true);
			}


		});
		
		$("#youhui_slide").find("li").find("input").click(function(){
			var parent = $(this).parent().parent();
			var yhj = parseFloat($("#yhj").text());
			var yuanjia = parseFloat($("#yuanjia").text());
			var pro_price = parseFloat($("#pro_jiage").text());
			var jiesheng = parseFloat($("#jiesheng").text());
			var ygj = parseFloat(parent.find(".ygj").text());
			var tcj = parseFloat(parent.find(".tcj").text());
			if($(this)[0].checked){
				
				parent.addClass("cur");
				$("#yhj").text(parseFloat(tcj + yhj).toFixed(2));
				$("#yuanjia").text(parseFloat(ygj + yuanjia).toFixed(2));
				yuanjia = parseFloat($("#yuanjia").text());
				yhj = parseFloat($("#yhj").text());
				$("#jiesheng").text(parseFloat(yuanjia - yhj).toFixed(2));
				$("#peijian_num").text(parent.parent().find("input:checked").length);

			}else{
				yuanjia = parseFloat($("#yuanjia").text());
				yhj = parseFloat($("#yhj").text())
				$("#yhj").text(parseFloat(yhj - tcj).toFixed(2));
				$("#yuanjia").text(parseFloat(yuanjia - ygj).toFixed(2));
				yuanjia = parseFloat($("#yuanjia").text());
				yhj = parseFloat($("#yhj").text())
				$("#jiesheng").text(parseFloat(yuanjia - yhj).toFixed(2));
				$("#peijian_num").text(parent.parent().find("input:checked").length);
				parent.removeClass("cur");	
			}
			
		});

	},
	pro_fixed : function(elem, wrapWidth){
		var _this = this;
		var top = $(elem).offset().top;
		var oH = $(elem).height() + 2;
		var isIE=!!window.ActiveXObject; 
		var isIE6=isIE&&!window.XMLHttpRequest;
		$(elem).after("<div id='placeHolder_fixed' class='cl'>&nbsp;</div>");
		$("#placeHolder_fixed").height(oH).hide();
		checkWidth();
		checkPosition();
		$(window).scroll(function(){
			checkWidth();
			checkPosition();
		});
		$(window).resize(function(){
			checkWidth();
			checkPosition();
		})
		function checkPosition(){
			if($(window).scrollTop() > top -10){
				$("#placeHolder_fixed").show();
				if(isIE6){
					ie6fixed();
				}else{
					$(elem).css({"position" : "fixed", left : $(window).width() / 2 - wrapWidth / 2 + 200,  top : 0, width : $(elem).width(), "z-index" : "9999"});
				}

			}else{
				$("#placeHolder_fixed").hide();
				$(elem).removeAttr("style");
			}

			function ie6fixed(){
				$(elem).css({"position" : "absolute", left : $(window).width() / 2 - wrapWidth / 2 + 200, top : $(window).scrollTop(), width : $(elem).width(), "z-index" : "9999"});
				
			}
		}
		function checkWidth(){
			if($(window).width() < 1190){
				wrapWidth = $(window).width();
			}else{
				wrapWidth = 1190;
			}
		}
	},
	/**
	 * [pro_time description]
	 * @param  {[Number]}   t      [时间，单位为毫秒]
	 * @param  {[function]}   func     [时间innerHTML]
	 * @param  {[type]}   obj      [显示时间元素]
	 * @param  {Function} callback [回调函数，可选]
	 * @return {[type]}            [description]
	 */
	pro_time : function(t,func,obj,callback){
		var self=this;
		this.time = t;
		this.start=function(){
			var tt=self.time/1000;
			var o={};
			o.time = self.time;
			o.seconds = parseInt(tt%60);
			o.minutes = parseInt((tt/60)%60);
			o.hours = parseInt((tt/60/60)%24);
			o.days = parseInt(tt/60/60/24);
			if(o.seconds < 10){o.seconds="0"+o.seconds;}
			if(o.minutes < 10){o.minutes="0"+o.minutes;}
			func(o,obj, callback);
			if(self.time >= 0){
				setTimeout(self.onRetime, 1000);
			}
		};
		this.onRetime = function(){
			self.time -= 1000;
			self.start();
		};	
	},
	pro_time_callback : function(){
		alert("抢购结束");
	},
	pro_reTime : function(time, obj, callback){
		if (time.time >= 0) {
			$(obj).html('剩<em>' + time.days + '</em>天<em>' + time.hours + '</em>小时<em>' + time.minutes + '</em>分<em>' + time.seconds + '</em>秒');
		}else{
			callback();
		}
	},
	pro_zhidao : function(){
		$("#zhidao_list").find("li").find(".answer").click(function(){
			$(this).parent().next().show();
			$(this).parent().next().find("textarea").keyup(function(){
				$(this).parent().find(".words_count em").html($(this).val().length);
				if($(this).val().length > 2000){
					alert("超过2000字，请适当删减文字！");
				}
			})
			$(this).hide();
		});
		$("#zhidao_list").find("li").find("a.closeBox").click(function(){
			$(this).parent().hide();
			$(this).parent().prev().find(".answer").show();
		});
		$("#zhidao_list").find("li").find(".user_answer_comments").each(function(){
			var _this = $(this);
			if($(this).html().length > 220){
				$(this).after('<a href="###" class="a1">[展开全部]</a>');
				$(this).next().toggle(function(){
					_this.height("auto");
					$(this).html("[收起内容]");
				},function(){
					_this.height("40px");
					$(this).html("[展开全部]");
				})
			}
		});

	},
	pro_canshu_more : function(i){
		$(this.btn).find(".arrow").animate({top : (i+1) * 65, left : 200});
		$(this.btn).find(".pro_canshu_inner").eq(i).show().parent().siblings().find(".pro_canshu_inner").hide();

	},
	pro_manyidu : function(){
		function showWidth(o){
			var i = 0;
			var move = setInterval(function(){
				//var d = Math.ceil((100 - i)/30);
				if(parseInt($(o).parent().attr("w")) == 0){
					i = 0;
				}else{
					i = i + 1;
				}
				$(o).width(i + "%");
				if(i >= parseInt($(o).parent().attr("w"))){
					//alert(0)
					clearInterval(move);
				}
			},15);

		}
		for(var i = 0; i < $(".stat_box").length; i++){
			showWidth($(".stat_box").find("span")[i]);
		}

	},
	/**
	 * [pro_jiucuo description]
	 * @param  {[type]} _id      [弹窗容器id]
	 * @param  {[type]} _closeId [关闭按钮id]
	 * @param  {[type]} _submit  [确认id]
	 * @return {[type]}          [description]
	 */
	pro_jiucuo : function(_id, _closeId, _submit, _hasMask){
		$PV.extend($PV.Ready.pro_jiucuo, Product);
		$("#pro_canshu_tab_box").find("tr").find(".erro_recovery").click(function(){
			$PV.Ready.pro_jiucuo.base.popBox.call(this, _id, _closeId, _submit);
		});
	},
	pro_share : function(id){
		var w = window.screen.width < 990 ? 990 : 0;
		var typeA = window.screen.width < 990 ? { left : w } : { right : 0 };
		$(id).css(typeA).show();
		$(window).scroll(function(){
			var type = window.screen.width < 990 ? {
				"top" : $(window).scrollTop() + 200,
				left : w
			} : {
				"top" : $(window).scrollTop() + 200,
				right : w
			}
			$(id).stop(true).animate(type);
		});
		/**/
		this.pro_hoverShow($(id).find(".share"), ".share_site");
	},
	pro_comment_goto : function(){
		$("#goto_comment").click(function(){
			$("#pro_detail_tab").find("li").eq(2).click();
			// $("body, html").animate({
			// 	scrollTop : $("#pro_detail_tab").offset().top
			// })
		});
	},
	pro_shoucang : function(_id, _closeId, _submit, _hasMask){
		$PV.extend($PV.Ready.pro_shoucang, Product);
		$("#shoucang").click(function(){
			$PV.Ready.pro_shoucang.base.popBox.call(this, _id, _closeId, _submit, true);
		});
	},
	pro_video_show : function(){
		$("#view_video").click(function(){
			if($("#video_area").find("a").length > 0){
				return;
			}
			$("#video_area").addClass("video_mask loadingB");
			var tmp_html = $("#video_html").html();
			$("#video_area").append(tmp_html);
		});
		$("#video_area").find("a.close").live("click", function(){
			$(this).prev().remove();
			$(this).remove();
			$("#video_area").removeClass("video_mask loadingB");
		})
	}
}

//执行开始
$(function(){
	
	$PV.cityBox().init();
	$PV.Ready.init();

})